/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.vnf.bc;

import edu.upn.sigemfi.vnf.be.TipoTransaccionNF;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Programador
 */
public class TipoTransaccionNFDelegate {

      private TipoTransaccionNFFacadeLocal local;

     public TipoTransaccionNFDelegate(){
        local = lookupTipoTransaccionNFFacade();
    }

     public void crear(TipoTransaccionNF tipoTransaccionNF) throws Exception{
         try {
             local.create(tipoTransaccionNF);
         } catch (Exception e) {
             local = lookupTipoTransaccionNFFacade();
             throw new Exception("Crear Tipo Transaccion No Financiera" + e.getMessage());
         }

     }

     public void editar(TipoTransaccionNF tipoTransaccionNF) throws Exception{
         try {
             local.edit(tipoTransaccionNF);
         } catch (Exception e) {
             local = lookupTipoTransaccionNFFacade();
             throw new Exception("Editar Tipo Transaccion No Financiera" + e.getMessage());
         }

     }

     public void eliminar(TipoTransaccionNF tipoTransaccionNF) throws Exception{
         try {
             local.remove(tipoTransaccionNF);
         } catch (Exception e) {
             local = lookupTipoTransaccionNFFacade();
             throw new Exception("Eliminar Tipo Transaccion No Financiera" + e.getMessage());
         }

     }


    private TipoTransaccionNFFacadeLocal lookupTipoTransaccionNFFacade() {
        try {
            Context c = new InitialContext();
            return (TipoTransaccionNFFacadeLocal) c.lookup("java:comp/env/TipoTransaccionNFFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
